#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	long long a[100],b[100];
	int count = 0;
	for (int i = 0; i < 100; i++)
	{
		cin >> a[i];
		count++;
		if (a[i] != 0)
		{
			b[i] = a[i];
		}
		if (a[i] == 0)
		{
			b[i] == ' ';
			break;
		}
	}
	for (int i=count-1;i>0;i--)
	{
		cout << b[i-1] << ' ';
	}
	return 0;
}